cc.Class({
    extends: cc.Component,

    properties: {
        skinAlta:cc.SpriteAtlas,

        tbullet:cc.Prefab,
       
    },

    // use this for initialization
    onLoad: function () {
        

    },

    init:function(type,rotation,speed){
        
        //将当前预制件的图片属性设置为该预制件上skinAlta图片集里面的单个图片
        this.getComponent(cc.Sprite).spriteFrame=this.skinAlta.getSpriteFrame("bullet"+type);
        this.node.rotation = rotation;
        this.speedX= speed * Math.sin(rotation/180*Math.PI);
        this.speedY= speed * Math.cos(rotation/180*Math.PI);


    },

   
    update: function (dt) {
        this.node.x+=this.speedX;
        this.node.y+=this.speedY;

        //子弹游出屏幕自动删除
        if( this.node.x <= -(cc.winSize.width/2+50+this.tbullet.width) || 
            this.node.x >= cc.winSize.width/2+50+this.tbullet.width || 
            this.node.y >= (610+this.tbullet.height) || 
            this.node.y <= -(610+this.tbullet.height)
          )
        {
            this.node.destroy();
        }

    },
});
